home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Precision Software Appli…tions Silver Collection 4
/
Precision Software Applications Silver Collection Volume 4 (1993).iso
/
stats
/
chadyn.exe
/
YCOM.C
< prev
next >
Wrap
Text File
|
1988-12-13
|
9KB
|
357 lines
/****************************** YCOM.C ***********************************/
/*********************(C) 1986,7,8 by JAMES A. YORKE ************************/
/********************** Routines in YCASES.c **************************
some routines in file:
select_item(CodeName)
GetCommandAndImplement(CodeName)
implementCommand(CodeName)
Entervalue(val, flag) gets value from keyboard and returns it as function value
EnterScale(pointer1,pointer2)
abortEnter()
ret_erase_line(i) gives i copies of return(plus line feed) + erase_line()
MaybeNewLine()
toggle(flag) prints " ON\n" or " OFF\n"
***************************************************************************/
#include "yinclud.h"
/*#define DEBUG*/
static char *NotToBeSet =
"\nThis variable should not be set for this process\n\n";
static int counter = 0;
/* The main menu is run by this function; it uses fscanf for input:
* enter a code like XS so you can then change the x scale using this
* routine; the changes can be either entered from the keyboard(when input
* == StInput) or from a file whose name was entered on the command line,
* that is the line used to tell the computer to run this program; in that
* case input is the pointer to that file.
*/
select_items(CodeName)
char *CodeName;
{
level = SETPARAM;
scr_clr(); /* in desmets pcio.a */
scr_rowcol(0, 0);
if(coloncommand == NO && input == StInput)
MainMenu();
while(level == SETPARAM) {
if(coloncommand == NO && input == StInput) {
erase_line();
PRINT
"Enter *(for HELP) or MM(for repeat of MainMenu) or other Menu item: \n");
erase_line();
}
GetCommandAndImplement(CodeName);
}
}
GetCommandAndImplement(CodeName)
char *CodeName;
{
if(GetCommand(CodeName) == 0)
return;
if(level >= PROCESS && printer > 0) {
scr_rowcol(0, 0);
erase_line();
ret_erase_line(4);
}
#ifdef DEBUG
fprintf(stderr, "implementCommand(%s)\n", CodeName);
pause(1.0);
#endif
implementCommand(CodeName);
}
implementCommand(CodeName)
char *CodeName;
{
int plot(), iterate_map();/* needed for pointers */
int connect(); /* needed for pointers */
TEST("+") {
counter++;
if(counter > 12)
counter = 0;
if(counter == 0)
MainMenu();
if(counter == 1)
menuV();
if(counter == 2) {
if(level == SETPARAM)
scr_clr();/* in desmets pcio.a */
scr_rowcol(0, 0);
PRINT
" MENU OF KEYBOARD INTERRUPTS --FOR USE WHILE PLOTTING \n");
getText("yintrpt.doc", "keys\n");
}
if(counter == 3)
menuP();/* parameters */
if(counter == 4)
menuY();
if(counter == 5)
DEMenu();/* parameters */
if(counter == 6)
diskMenu();
if(counter == 7)
BasinMenu();
if(counter == 8)
StraddleMenu();
if(counter == 9)
NewtonMenu();
if(counter == 10)
ManifoldMenu();/* "u" */
if(counter == 11)
ColorMenu(); /* command "cm"; in YSCREEN.C */
if(counter == 12)
bifMenu();
return;
}
if(MMCommands(CodeName) == 1)
return;
if(UndocumentedCommands(CodeName) == 1)
return;
if(DECommands(CodeName) == 1)
return;
if(VCommands(CodeName) == 1) /* various and sundry */
return;
if(parameters(CodeName) == 1)
return;
if(Ycommands(CodeName) == 1)
return;
if(caseBs(CodeName) == 1)
return;
if(caseDs(CodeName) == 1)
return;
if(caseNs(CodeName) == 1)
return;
if(caseColor(CodeName) == 1) /* in YSCREEN.C */
return;
if(caseUs(CodeName) == 1)
return;
if(bifCommands(CodeName) == 1)
return;
PRINT
"\n * * * * ******** %s: Not a Parameter Menu Item ******** * * * * \n\n"
,CodeName);
}
/* ENTERVALUE - enter a value from the keyboard. The current value
* is passed as the function argument. When SETIT is nonzero, the value is
* obtained unconditionally. Otherwise, if SETIT is zero, and the value is
* the magic number and we're not supposed to set the value, then an error
* message is printed and the function returns the original value.
* Otherwise, the value is obtained from the keyboard. The user has the option
* of aborting the input, which leaves the current value unchanged.
*/
double Entervalue(val, setit)
double val;
int setit;
{
double newval;
/* can read this variable if initializerFlag == YES */
if(!setit && val == -9999.0 && initializerFlag == NO)
{
PRINT NotToBeSet);
return(val);
}
/* SCREEN means (SCREEN_MENU || SCREEN_PROCESS)
SCREEN_MENU means (level <=2 && coloncommand == NO && input==StInput)
SCREEN_PROCESS means (level >= PROCESS && printer > 0 )
*/
if(SCREEN)
{
if (level > 2)
scr_rowcol(0,0);
erase_line();
PRINT
"Current value: %.12g. Enter value (and then 'Enter'):", val);
MaybeNewLine();
}
#ifdef X11
fflush(printWhere());
if(input == StInput && sscanf(xwfgets(),"%lf",&newval) == 1
|| input != StInput && fscanf(input, "%lf", &newval) == 1) {
#else
if(abortEnter() != YES && fscanf(input, "%lf", &newval) == 1){
#endif
val = newval;
if(SCREEN)
{ erase_line();
PRINT "New value: %.14g", val);
ret_erase_line(1);
}
} else if(SCREEN) {
erase_line();
PRINT "*** Value unchanged *** \n\n");
}
return(val);
}
Enter4Int(pointer1, pointer2, pointer3, pointer4)
int *pointer1,
*pointer2,
*pointer3,
*pointer4;
{
int newval[4];
if(SCREEN) {
erase_line();
PRINT
"Current values: %d %d %d %d. Enter 4 integers (and then 'Enter'):"
,*pointer1, *pointer2, *pointer3, *pointer4);
MaybeNewLine();
}
#ifdef X11
if(input == StInput && sscanf(xwfgets(), "%d %d %d %d",
newval, &newval[1], &newval[2], &newval[3]) == 4
|| input != StInput && fscanf(input, "%d %d %d %d",
newval, &newval[1], &newval[2], &newval[3]) == 4) {
*pointer1 = newval[0];
*pointer2 = newval[1];
*pointer3 = newval[2];
*pointer4 = newval[3];
#else
if(abortEnter() == YES)
return;
if(fscanf(input, "%d %d %d %d", newval, newval + 1, newval + 2,
newval + 3) == 4) {
*pointer1 = newval[0];
*pointer2 = newval[1];
*pointer3 = newval[2];
*pointer4 = newval[3];
#endif
if(SCREEN) {
erase_line();
PRINT "New values: %d %d %d %d\n",
newval[0], newval[1], newval[2], newval[3]);
ret_erase_line(2);
}
} else if(SCREEN) {
erase_line();
PRINT "*** Values unchanged *** \n");
ret_erase_line(2);
}
return;
}
#ifndef X11
int abortEnter() { /* for terminating a command without changing
values; specifically: checks to see if input
is '\n'; if so it aborts; otherwise is puts
the character back in the stream "input"; it
discards any leading spaces */
/* char chr;
*/ int ch;
/* SCREEN means (SCREEN_MENU || SCREEN_PROCESS)
SCREEN_MENU means (level <=2 && coloncommand == NO && input==StInput)
SCREEN_PROCESS means (level >= PROCESS && printer > 0 )
*/
if (SCREEN_MENU || level >= PROCESS)
{
ch = getc(input);
if(ch == ' ' || ch == '\n') {
/* there is probably a return still in the
pipeline from entering the command so this
one should not cause an abort */
ch = getc(input);
}
while(ch == ' ' || ch == '\n') {
if(ch == '\n') {
PRINT "\n");
return(YES);
}
ch = getc(input);
}
ungetc(ch, input);
}
return(NO);
}
#endif /* X11 */
MaybeNewLine()
{
if(level >= PROCESS)
ret_erase_line(1);
}
EnterScale(pointer1, pointer2)
double *pointer1,
*pointer2;
{
double newval[2];
if(SCREEN) {
PRINT
"Current scale runs from %.14g to %.14g\n", *pointer1, *pointer2);
PRINT
"Enter 2 numbers separated by a space, no comma, then 'return'\n");
erase_line();
}
#ifdef X11
if(input == StInput && sscanf(xwfgets(), "%lf %lf",
newval, &newval[1]) == 2 || input != StInput
&& fscanf(input, "%lf %lf", newval, &newval[1]) == 2) {
#else
if(abortEnter() != YES && fscanf(input, "%lf %lf", newval, &newval[1])
== 2) {
#endif
*pointer1 = newval[0];
*pointer2 = newval[1];
if(SCREEN)
PRINT "New scale runs from %.14g to %.14g\n",
newval[0], newval[1]);
if(newval[0] == newval[1]) {
erase_line();
PRINT "WARNING:NEW VALUES ARE EQUAL; THEY MUST BE RESET");
ret_erase_line(2);
}
} else if(SCREEN) {
PRINT "*** Values unchanged\n");
}
return;
}
toggle(flag) /* prints " ON\n" or " OFF\n" */
int flag;
{
if(flag == ON)
PRINT " ON \n");
else if(flag == OFF)
PRINT " OFF \n");
else
PRINT "%d \n", flag);
}
incrementD(p, CodeName)
double *p;
char *CodeName;
{
if(*p == -9999.&& initializerFlag == NO) {
/* can read this variable if initializerFlag ==
YES */
PRINT "This variable is not set and cannot be incremented.\n");
return;
}
pIncrement = p;
if(SCREEN) {
erase_line();
PRINT
"%s = %g will be incremented by interrupts +/- by RS=%g\n",
CodeName, *pIncrement, rho_step);
}
}